package ee.logsimulator.parser.data;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class Raid {

  public String date;
  public String link;
  public String onmouseover;
  public ReportData report;
  public List<Boss> bosses = new ArrayList<Boss>();

  public Raid(String date, String link, String onmouseover) {
    this.date = date;
    this.link = link;
    this.onmouseover = onmouseover;
  }

  public String getName() {
    String name = " ";
    boolean first = true;
    for (Zone zone : report.zones) {
      if (!first) {
        name += "/";
      } else {
        first = false;
      }
      name += zone.name;
    }
    return date + name;
  }

  public Map<String, List<Boss>> getBosses() {
    Map<String, List<Boss>> map = new LinkedHashMap<String, List<Boss>>();
    for (Boss boss : bosses) {
      if (boss.isWipe()) {
        String[] split = boss.name.split(" Try ");
        List<Boss> list = map.get(split[0]);
        if (list == null) {
          list = new ArrayList<Boss>();
          map.put(split[0], list);
        }
        list.add(boss);
      } else {
        String[] split = boss.name.split(" \\(");
        List<Boss> list = map.get(split[0]);
        if (list == null) {
          list = new ArrayList<Boss>();
          map.put(split[0], list);
        }
        list.add(boss);
      }
    }
    return map;
  }
}
